package test;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class WuLian extends ActionSupport {
	@Override
	public String execute() throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/xml;charset=utf-8");
		PrintWriter out = response.getWriter();

		String orderId = request.getParameter("order_id");
		String auctionId = request.getParameter("auction_id");
		String buyQuantity = request.getParameter("buy_quantity");
		String orderPrice = request.getParameter("order_price");
		String linkMan = request.getParameter("link_man");
		String mobile = request.getParameter("mobile");
		String skuAttr = request.getParameter("sku_attr");
		String username = request.getParameter("username");
		String password=request.getParameter("password");
		String payWay=request.getParameter("pay_way");
		if(skuAttr!=null){
		skuAttr=new String(skuAttr.getBytes("iso-8859-1"),"utf-8");
		}
		if(username!=null){
		username=new String(username.getBytes("iso-8859-1"),"utf-8");
		}
		if(linkMan!=null){
		linkMan=new String(linkMan.getBytes("iso-8859-1"),"utf-8"); 
		}
		System.err.println(skuAttr);
		System.err.println(username);
		System.out.println(password);
		//System.err.println(URLDecoder.decode(skuAttr,"utf8"));
		//skuAttr=URLEncoder.encode(skuAttr,"utf8");
		StringBuilder sb = new StringBuilder();
		String message = sb.append("order_id=" + orderId ).append(
				"auctionId=" + auctionId ).append(
				"buyQuantity=" + buyQuantity ).append(
				"orderPrice=" + orderPrice ).append(
				"linkMan=" + linkMan ).append("mobile=" + mobile )
				.append("username="+username)
				.append("password="+"密码")
				.append("skuAttr=" +skuAttr )
				.append("payWay="+payWay)
				.toString();

		String s = "<?xml version=\"1.0\" encoding=\"utf-8\"?><response><is_success>T</is_success><message>"
				+ message + "</message></response>";
		out.print(s);

		return null;
	}

}
